'use strict';
var React = require('react');
var HomeProductItems=require('./HomeProductItems.jsx');
class HkfsProductTable extends React.Component {
    constructor(props) {
        super(props);
        this.renderTitle = this.renderTitle.bind(this);
        this.renderContent=this.renderContent.bind(this);
    }

    //渲染标题
    renderTitle() {
        let itemWidth = this.props.widthArray;
        return this.props.title.map((item, i)=> {
            let style={
                width:itemWidth[i]
            };
            return <div key={"HkfsProductTable_TitleItem"+i} className="HkfsProductTable_TitleItem" style={style}>{item}</div>
        });
    }

    renderContent(){
        let widthArray = this.props.widthArray;
        return this.props.data.map((item,i)=>{
            return <HomeProductItems key={"HomeProductItems" +i} content={item}  widthArray={widthArray} itemTypes={this.props.itemTypes} buttonText={this.props.buttonText} itemHref={this.props.itemHref}></HomeProductItems>
        });
    }

    render(){
        return(
            <div className="HkfsProductTable_Container">
                <div className="HkfsProductTable_Title">
                    {this.renderTitle()}
                </div>
                <div className="HkfsProductTable_Content">
                    {this.renderContent()}
                </div>
            </div>
        )
    }
}

module.exports=HkfsProductTable;